package com.mcflies.aotoPartsManager.action;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import com.mcflies.aotoPartsManager.pojo.CustomerArea;
import com.mcflies.aotoPartsManager.service.CustomerAreaService;
import com.mcflies.aotoPartsManager.util.AutoPartsConstantKey;
import com.mcflies.aotoPartsManager.util.AutoPartsServiceFactory;
import com.mcflies.commons.commons.CommonFunction;

import net.sf.json.JSONObject;

/**
 * 
 * AutoPartsAreaAction.java
 * 
 * @describe：AutoParts项目：：客户地域相关信息Action请求响应类
 * @Copyright(c) 2012-2024 Study,mcfly
 * @author mcfly_jun
 */
public class AutoPartsAreaAction {
	private Logger log = Logger.getLogger(AutoPartsAreaAction.class);
	private JSONObject resultObj = new JSONObject();
	private CustomerArea area;
	private int limit;
	private int start;

	public String loadAllArea() {
		try {
			CustomerAreaService areaService = AutoPartsServiceFactory.initCustomerAreaService();
			resultObj = areaService.loadCustomerAreaWithPage(start, limit);
		} catch (Exception e) {
			log.info("在[" + AutoPartsAreaAction.class.getName() + "]执行方法(loadAllArea)出现：：" + e.getMessage() + "异常");
		}
		return AutoPartsConstantKey.RETURN_JSON_OBJECT_TYPE;
	}

	public String newArea() {
		Map<String, Object> retMap = new HashMap<String, Object>();
		try {
			CustomerAreaService areaService = AutoPartsServiceFactory.initCustomerAreaService();
			retMap = areaService.addCustomerArea(area);
			resultObj = CommonFunction.showSuccessInfo(retMap);
		} catch (Exception e) {
			log.info("在[" + AutoPartsAreaAction.class.getName() + "]执行方法(newArea)出现：：" + e.getMessage() + "异常");
			resultObj = CommonFunction.showErrorInfo(retMap, e);
		}
		return AutoPartsConstantKey.RETURN_JSON_OBJECT_TYPE;
	}

	public JSONObject getResultObj() {
		return resultObj;
	}

	public void setResultObj(JSONObject resultObj) {
		this.resultObj = resultObj;
	}

	public CustomerArea getArea() {
		return area;
	}

	public void setArea(CustomerArea area) {
		this.area = area;
	}

	public int getLimit() {
		return limit;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}

	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}
}
